package refactor.changebidirectionalassociationtounidirectional;

import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

public class Customer {
    private String name;
    private Set<Order> orders = new HashSet<>();

    public Customer(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public Set<Order> getOrders() {
        return orders;
    }

    public void addOrder(Order order) {
        orders.add(order);
    }

    public String state() {
        return "customer name:" + name + "，order id:" + orders.stream().map(Order::getId)
                .collect(Collectors.joining(","));
    }

}
